#ifndef __COMPONENT_CREATURE_MODEL_H__
#define __COMPONENT_CREATURE_MODEL_H__

#include <memory>
#include <mutex>
#include "Component.hpp"
#include "Engine/Vector3.hpp"
#include "Engine/Quaternion.h"
#include "GameLock.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    struct ComponentCreature;

    struct ComponentCreatureModel : public Component
    {
    protected:
        Vector3 m_randomLookPoint;

        std::shared_ptr<Vector3> eyePosition = nullptr;
        std::shared_ptr<Quaternion> eyeRotation = nullptr;
        SpinLock m_eyeLock;

    public:
        std::shared_ptr<Vector3> lookAtOrder = nullptr;
        bool lookRandomOrder;

        ComponentCreature *componentCreature;
        
        Vector3 getEyePosition();
        Quaternion getEyeRotation();
        
        virtual std::shared_ptr<Vector3> calculateEyePosition();
        virtual std::shared_ptr<Quaternion> calculateEyeRotation();


        virtual void update(float dt) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
        virtual void load(const nlohmann::json &jsonData) override;
        virtual void save(nlohmann::json &jsonData) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;

        void eyePositionClear();
        void eyeRotationClear();
    };
    
} // namespace PocketSurvival

#endif
